/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package datas;

import beans.Account;
import java.sql.CallableStatement;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Administrator
 */
public class AccountObj {

    private connect con;

    public AccountObj() {
        con = new connect();
    }

    public int InsertAcc(Account acc) {
        try {
            CallableStatement csInsert = con.getConnect().prepareCall("{call AddAccount(?,?,?)}");
            csInsert.setString(1, acc.getAccountNo());
            csInsert.setString(2, acc.getPassword());
            csInsert.setInt(3, acc.getAmount());
            return csInsert.executeUpdate();
        } catch (SQLException ex) {
            Logger.getLogger(AccountObj.class.getName()).log(Level.SEVERE, null, ex);
        }
        return 0;
    }

    public boolean CheckAcc(String user,String pass){
        try {
            CallableStatement csCheck = con.getConnect().prepareCall("{call CheckAccount(?,?)}");
            csCheck.setString(1, user);
            csCheck.setString(2, pass);
            return csCheck.execute();
        } catch (SQLException ex) {
            Logger.getLogger(AccountObj.class.getName()).log(Level.SEVERE, null, ex);
        }
        return false;
    }
}
